package collections

import "errors"

var (
	errIllegalIndex   = errors.New("out of range")
	defaultLoadFactor = 0.75
	defaultCapacity   = 1 << 4
)

type ArrayList struct {
	data []interface{}
	size int
}

func NewArrayList(capacity int, loadFactor float64) *ArrayList {
	if loadFactor <= 0 {
		loadFactor = defaultLoadFactor
	}

	if capacity <= 0 {
		capacity = defaultCapacity
	}

	return &ArrayList{
		data: make([]interface{}, 0, capacity),
		size: 0,
	}
}

func (a ArrayList) Add(element interface{}) {

}

func (a ArrayList) Size() int {
	return a.size
}

func (a ArrayList) Remove(index int) interface{} {
	panic("implement me")
}

func (a ArrayList) Get(index int) interface{} {
	panic("implement me")
}

func (a ArrayList) Find(element interface{}) int {
	panic("implement me")
}

func (a ArrayList) checkIndex(idx int) error {
	if idx < 0 || idx > a.size {
		return errIllegalIndex
	}
	return nil
}
